package com.loe.ktui

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.loe.ktui.ui.KtTextView
import com.loe.ktui.ui.ui_FrameLayout
import com.loe.ktui.ui.ui_Text
import com.loe.ktui.util.KtColor
import kotlin.concurrent.thread
import kotlin.random.Random

class TestFragment : Fragment()
{
    private val name by lazy { arguments?.getString("name") ?: "" }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View?
    {
        return ui_FrameLayout()
        {
            bg = KtColor.cyan
            ui_Text()
            {
                id = "textView"
                text = "fragment几乎都是房间号东风浩荡好多商家第三方副科级\n" + Random.nextLong(9999999999)
            }
        }.createView(inflater.context)
    }

    private val textView: KtTextView get() = findView("textView")

    override fun onViewCreated(view: View, savedInstanceState: Bundle?)
    {
        super.onViewCreated(view, savedInstanceState)

        textView.text = name + toString()
    }

    override fun onResume()
    {
        Log.d("runtime onResume: ", toString())
        super.onResume()
    }

    override fun onPause()
    {
        Log.d("runtime onPause: ", toString())
        super.onPause()
    }

    override fun onDestroy()
    {
        Log.d("runtime onDestroy: ", toString())
        super.onDestroy()
    }
}